home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
BARNET
/
FREENET
/
FERGUSON
/
CLIENT_P
/
!Client_Ex
/
c
/
Client_Ex
< prev
next >
Wrap
Text File
|
1995-06-04
|
6KB
|
218 lines
/*
File: Client_Ex.c
Author: © 1993 &1994 by Duncan Ferguson
Version: v0.01 22-Jan-1995
Purpose: Basic C application template
*/
/* ============================================================= */
/* | Include files | */
/* ============================================================= */
#include "ProgInfo.h"
#include "Address.h"
#include "Connect.h"
#include "Command.h"
#include "DeskLib:Error.h"
#include "DeskLib:Event.h"
#include "DeskLib:EventMsg.h"
#include "DeskLib:Handler.h"
#include "DeskLib:Icon.h"
#include "DeskLib:Resource.h"
#include "DeskLib:Menu.h"
#include "DeskLib:Msgs.h"
#include "DeskLib:Screen.h"
#include "DeskLib:Template.h"
#include "DeskLib:WIMP.h"
#include "DeskLib:WimpSWIs.h"
#include "DeskLib:Window.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* ============================================================= */
/* | #Definitions | */
/* ============================================================= */
#define NEVER_REACH_HERE FALSE
/* ============================================================= */
/* | Structures | */
/* ============================================================= */
enum {
iconmenu_INFORMATION,
iconmenu_QUIT
};
enum {
proginfo_NAME = 1,
proginfo_AUTHOR,
proginfo_PURPOSE,
proginfo_VERSION
};
enum {
ApplicationNameLength = 64,
ApplicationPurposeLength = 64,
ApplicationVersionLength = 30,
ApplicationMenuLength = 260
};
/* ============================================================= */
/* | Global variables | */
/* ============================================================= */
/* Window and menu handles */
static menu_ptr Icon_Menu = NULL;
static icon_handle Bar_Icon = 0;
static window_handle Prog_Info = 0;
/* menu variables needd */
static BOOL Quit = FALSE;
/* ============================================================= */
/* | Function Prototypes | */
/* ============================================================= */
static BOOL IconBarMenuChoice( event_pollblock *event, void *reference);
static BOOL IconBarClick( event_pollblock *event, void *reference);
static BOOL UserMessage( event_pollblock *event, void *reference);
static BOOL DataLoad_Message( event_pollblock *event, void *reference);
/* ============================================================= */
/* | External functions | */
/* ============================================================= */
int main(int argc, char *argv[])
{
char ApplicationName[ApplicationNameLength+1];
char ApplicationPurpose[ApplicationPurposeLength+1];
char ApplicationVersion[ApplicationVersionLength+1];
char MenuDescription[ApplicationMenuLength+1];
const unsigned int RiscVersion = 310;
UNUSED(argc);
UNUSED(argv);
Resource_Initialise("Client_Ex");
if(!Msgs_LoadFile("Resources.Messages"))
{
Error_ReportFatal(1, "Resources could not be found");
}
Msgs_Lookup("app.name", ApplicationName, ApplicationNameLength);
Event_Initialise3(ApplicationName, RiscVersion, NULL);
EventMsg_Initialise();
Screen_CacheModeInfo();
EventMsg_Claim(message_MODECHANGE, event_ANY, Handler_ModeChange, NULL);
Template_Initialise();
Template_UseOutlineFonts();
Template_LoadFile("Resources.Templates");
Msgs_Lookup("app.purpose",ApplicationPurpose, ApplicationPurposeLength);
Msgs_Lookup("app.version:0.00",ApplicationVersion, ApplicationVersionLength);
strcat(ApplicationVersion, DATE);
Prog_Info = Window_Create("ProgInfo", 0);
Icon_SetText(Prog_Info, proginfo_NAME, ApplicationName);
Icon_SetText(Prog_Info, proginfo_AUTHOR, ApplicationPurpose);
Icon_SetText(Prog_Info, proginfo_PURPOSE, AUTHOR);
Icon_SetText(Prog_Info, proginfo_VERSION, ApplicationVersion);
Msgs_Lookup("app.mainmenu", MenuDescription, ApplicationMenuLength);
Icon_Menu = Menu_New(ApplicationName, MenuDescription);
Menu_AddSubMenu(Icon_Menu, iconmenu_INFORMATION, (menu_ptr)Prog_Info);
Event_Claim(event_OPEN, event_ANY, event_ANY, Handler_OpenWindow, NULL);
Event_Claim(event_CLICK, event_ANY, event_ANY, IconBarClick, NULL);
Event_Claim(event_MENU, event_ANY, event_ANY, IconBarMenuChoice, NULL);
setbuf(stderr, NULL);
setbuf(stdout, NULL);
if(Connect_Initialise())
{
/* put icon on icon bar here so icon bar doesnt flicker if failed */
Bar_Icon = Icon_BarIcon(ApplicationName, iconbar_RIGHT);
Address_ContactServer();
Command_Open();
}
else
{
/* Error messages are given within connect module for the problem */
Quit = TRUE;
}
while(!Quit)
{
Connect_WimpPoll();
}
Connect_Shutdown();
return FALSE;
}
extern Client_Ex_RequestQuit(void)
{
Quit = TRUE;
}
/* ============================================================= */
/* | Internal functions | */
/* ============================================================= */
static BOOL IconBarMenuChoice(event_pollblock *event, void *reference)
{
mouse_block ptr;
UNUSED(reference);
if(menu_currentopen != Icon_Menu) return FALSE;
switch(event->data.selection[0])
{
case iconmenu_INFORMATION:
break;
case iconmenu_QUIT:
Quit = TRUE;
break;
default:
assert(NEVER_REACH_HERE);
break;
}
Wimp_GetPointerInfo(&ptr);
if(ptr.button.data.adjust) Menu_ShowLast();
return TRUE;
}
static BOOL IconBarClick(event_pollblock *event, void *reference)
{
int ypos = -1;
UNUSED(reference);
if(event->data.mouse.button.data.menu)
{
Menu_Show(Icon_Menu, event->data.mouse.pos.x, ypos);
}
if(event->data.mouse.button.data.select)
{
Command_Open();
}
return TRUE;
}